<?php echo theme_js('jquery.fancybox.js?v=2.1.5', true);?>
<?php echo theme_css('slider.css', true);?>
<script type="text/javascript">
  $(document).ready(function() {
	  $('.fancybox').fancybox();
  });
</script>
<!-- right -->
            <div class="col-md-9">
				<?php include ("breadcrumb.php");?>
                <?php if($category->image!=''){?>
                <div class="banner_list_sanpham">
               
                	<a href="#"><img src="<?php echo base_url('uploads/images/full/'.$category->image);?>"></a>
                </div>
				<?php }?>
                <div class="list_product_title">
                	<div class="list_product_title_1">
                		<!--<h3><?php echo $category->name;?> > <?php echo $product->name;?></h3> -->
                	</div>
                    <!--
                    <div class="list_product_title_2">
                		<p>Hiện đang có <span class="red"><?php echo $product_count;?></span> sản phẩm</p>
                	</div>
                    -->
                </div>
            	<?php /*
                <div class="banner_list_sanpham">
                	<a href="#"><img src="<?php echo base_url(ASSETPATH.'images/product_detail.png');?>"></a>
                </div>
                <div class="filte_pagi_wp">
                <div class="col-xs-12 col-sm-6 col-md-6">
                    <div class="icon_Cart_lage"><i class="fa fa-shopping-cart"></i></div>
                </div>
                <div class="clear"></div>
                </div>
				*/ ?>
                <!--box list san pham-->
                <div class="product_detail_wp" style="padding-bottom:0px">
                	<div class="product_detail">
                    	<div class="col-xs-12 col-sm-6 col-md-6">
                        	<div class="product_detail_img">
                            	<div class="flexslider" style="overflow:hidden">
                                <?php if(!empty($product->active_docquyen))echo '<div class="rolate_image">Độc quyền</div>'?>
                                <div class="kinhlup">
                                	<img src="<?php echo base_url(ASSETPATH.'images/kinhlup.png')?>">
                                 </div>
                                  <ul class="slides">
                                  
                                  	<?php if(count($product->images) > 0):?>                                        
									  <?php foreach($product->images as $image):?>
                                      <li data-thumb="<?php echo base_url('uploads/images/thumbnails/'.$image->filename);?>">
                                        <a class="fancybox" data-fancybox-group="gallery"><img alt="<?php echo $product->name;?>" src="<?php echo base_url('uploads/images/medium/'.$image->filename);?>" /></a>
                                      </li>
                                      <?php endforeach;?>
                                    <?php endif;?>
                                    
                                  </ul>
                                </div>
                            </div>
                        </div>
                        
                        <div class="col-xs-12 col-sm-6 col-md-6">
                        	<div class="product_detail_description">
                              <div class="product_detail_description_title">
                                    <h3 class="red"><?php echo $product->name;?></h3>
                                </div>
                                <p class="maso_sp" style=" padding-bottom:0px;"><span>MSP: </span><?php echo $product->sku;?></p>
                                <div class="product_list_thanhtoan_1">
                                	<?php /* <p class="giamgia"><strong>Giá thông thường</strong></p> */?>
                                            <p style="float:left"><span class="gia"><strong>Giá:</strong></span>
                                            	<?php if($product->saleprice < $product->price and $product->saleprice > 0){?>
                                                <span style="text-decoration:line-through"> <?php echo  format_currency($product->price);?></span>
                                                <?php }?>
                                                <span class="product_detail_price red">
                                                	<?php if($product->saleprice > 0){
																$real_price = $product->saleprice;
																echo format_currency($product->saleprice);
														}else{
															$real_price = $product->price;
															echo format_currency($product->price);
														}
													?>
                                                </span>
                                            </p>
                                            <?php /*  <p><span class="thue">(chưa bao gồm thuế)</span></p> */?>
                                            <?php if($product->score!=''){?>
                                            <p style="float:right;width:70px">Điểm: <span class="red"><?php echo $product->score;?></span></p>
                                            
                                            <?php }else if($this->score_price["price_one_score"]>0){?>
                                            <p style="float:right;width:70px">Điểm: <span class="red"><?php echo floor($real_price/$this->score_price["price_one_score"])?></span></p>
                                            <?php }?>
                                            <div class="clear"></div>
                                            <?php // if($product->quantity <=0) echo '<p style="color:#d39c2c;"> Sản phẩm đang về </p>'?>			
                                            <?php echo form_open('cart/add_to_cart', 'class="form-horizontal"');?>
                                            <input type="hidden" name="cartkey" value="<?php echo $this->session->flashdata('cartkey');?>" />
                                            <input type="hidden" name="id" value="<?php echo $product->id?>"/>
                                            <fieldset>
                                            
                                            <!--
                                            <div class="mausac_wp">
                                            	<?php if(count($options) > 0): ?>
													<?php foreach($options as $option):
                                                        $required   = '';
                                                        if($option->required)
                                                        {
                                                            $required = ' <p class="help-block">Required</p>';
                                                        }
                                                        ?>
                                                        <div class="control-group">
                                                            <label class="control-label" style="margin-bottom:7px"><?php echo $option->name;?></label>
                                                            <?php
                                                            /*
                                                            this is where we generate the options and either use default values, or previously posted variables
                                                            that we either returned for errors, or in some other releases of Go Cart the user may be editing
                                                            and entry in their cart.*/
                                                           
                                                           
                                                            //if we're dealing with a textfield or text area, grab the option value and store it in value
                                                            if($option->type == 'checklist')
                                                            {
                                                                $value  = array();
                                                                if($posted_options && isset($posted_options[$option->id]))
                                                                {
                                                                    $value  = $posted_options[$option->id];
                                                                }
                                                            }
                                                            else
                                                            {
                                                                if(isset($option->values[0]))
                                                                {
                                                                    $value  = $option->values[0]->value;
                                                                    if($posted_options && isset($posted_options[$option->id]))
                                                                    {
                                                                        $value  = $posted_options[$option->id];
                                                                    }
                                                                }
                                                                else
                                                                {
                                                                    $value = false;
                                                                }
                                                            }
                                                            if($option->type == 'textfield'):?>
                                                                <div class="controls">
                                                                    <input type="text" name="option[<?php echo $option->id;?>]" value="<?php echo $value;?>" class="span4"/>
                                                                    <?php echo $required;?>
                                                                </div>
																<?php elseif($option->type == 'textarea'):?>
                                                                    <div class="controls">
                                                                        <textarea class="span4" name="option[<?php echo $option->id;?>]"><?php echo $value;?></textarea>
                                                                        <?php echo $required;?>
                                                                    </div>
                                                                <?php elseif($option->type == 'droplist'):?>
                                                                <div class="controls">
                                                                    <select name="option[<?php echo $option->id;?>]">
                                                                        <option value=""><?php echo lang('choose_option');?></option>
                                                                    <?php foreach ($option->values as $values):
                                                                        $selected   = '';
                                                                        if($value == $values->id)
                                                                        {
                                                                            $selected   = ' selected="selected"';
                                                                        }?>
                                                                        <option<?php echo $selected;?> value="<?php echo $values->id;?>">
                                                                            <?php echo($values->price != 0)?' (+'.format_currency($values->price).') ':''; echo $values->name;?>
                                                                        </option>
                            
                                                                    <?php endforeach;?>
                                                                    </select>
                                                                    <?php echo $required;?>
                                                                </div>
                                                            <?php elseif($option->type == 'radiolist'):?>
                                                                <div class="controls">
                                                                    <?php foreach ($option->values as $values):
                            
                                                                        $checked = '';
                                                                        if($value == $values->id)
                                                                        {
                                                                            $checked = ' checked="checked"';
                                                                        }?>
                                                                        <label class="radio">
                                                                            <input<?php echo $checked;?> type="radio" name="option[<?php echo $option->id;?>]" value="<?php echo $values->id;?>"/>
                                                                            <?php echo($values->price != 0)?'(+'.format_currency($values->price).') ':''; echo $values->name;?>
                                                                        </label>
                                                                    <?php endforeach;?>
                                                                    <?php echo $required;?>
                                                                </div>
                                                            <?php elseif($option->type == 'checklist'):?>
                                                                <div class="controls">
                                                                    <?php foreach ($option->values as $values):
                            
                                                                        $checked = '';
                                                                        if(in_array($values->id, $value))
                                                                        {
                                                                            $checked = ' checked="checked"';
                                                                        }?>
                                                                        <label class="checkbox">
                                                                            <input<?php echo $checked;?> type="checkbox" name="option[<?php echo $option->id;?>][]" value="<?php echo $values->id;?>"/>
                                                                            <?php echo($values->price != 0)?'('.format_currency($values->price).') ':''; echo $values->name;?>
                                                                        </label>
                                                                    <?php endforeach; ?>
                                                                </div>
                                                                <?php echo $required;?>
                                                            <?php endif;?>
                                                            </div>
                                                    <?php endforeach;?>
                                                <?php endif;?>
                                            </div> -->
                                            <div>
                                            	<?php if(!config_item('inventory_enabled') || config_item('allow_os_purchase') || !(bool)$product->track_stock || $product->quantity > 0) : ?>
                                                <?php endif; ?>
                                                
                                                <div class="controls">
                                                    <?php if(!config_item('inventory_enabled') || config_item('allow_os_purchase') || !(bool)$product->track_stock || $product->quantity > 0) : ?>
                                                        <?php if(!$product->fixed_quantity) : ?>
                                                            Số lượng &nbsp;<input style="width:45px; text-align:center" class="span2" type="text" name="quantity" value="1"/>&nbsp;&nbsp;&nbsp;
                                                        <?php endif; ?>
                                                        <button style="border:none; margin-top:0px;" class="muasanpham" type="submit" value="submit"><i class="fa fa-shopping-cart"></i> <?php echo lang('form_add_to_cart');?></button>
                                                    <?php endif;?>
                                                </div>
                                            </div>
                                        </fieldset>
                                        </form>
                                    	</div>
                                <?php /*
                                <!-- Gia mua theo chu ky-->
                                <!--
                                <div class="product_list_thanhtoan_2">
                                	<p class="giamgia"><strong>Giá khi mua định kỳ</strong></p>
                                    <p><span class="gia"><strong>Giá:</strong></span></p>
                                    <p>
                                        <span class="product_detail_price red">
                                            <?php if($product->saleprice > 0)echo format_currency($product->saleprice);
                                                    else echo format_currency($product->price);
                                            ?>
                                        </span>
                                    </p>
                                    <p><span class="thue">(bao gồm thuế)</span></p>
                                    <p>Điểm: <span class="red">19 Pt</span></p>
                                    <p class="red">1 tháng mua 1 lần được giảm ..% cho lần sau</p>
                                    <div class="mausac_wp">
                                    	<p><span class="mau">Màu sắc:</span></p>
                                            <select name="">
                                            	<optgroup>
                                                	<option>1</option>
                                                    <option>1</option>
                                                    <option>1</option>
                                                </optgroup>
                                            </select>
                                    </div>
                                    <div class="thoigiangiaohang_wp">
                                            <p><span class="mau">Thời gian giao hàng:</span></p>
                                            <select name="">
                                            	<optgroup>
                                                	<option>1</option>
                                                    <option>1</option>
                                                    <option>1</option>
                                                </optgroup>
                                            </select>
                                    </div>
                                    <div>
                                        <label class="control-label"><?php echo lang('quantity') ?></label>
                                        <div class="controls">
                                            <?php if(!config_item('inventory_enabled') || config_item('allow_os_purchase') || !(bool)$product->track_stock || $product->quantity > 0) : ?>
                                                <?php if(!$product->fixed_quantity) : ?>
                                                    <input style="width:65px; text-align:center" class="span2" type="text" name="quantity" value="1"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                                <?php endif; ?>
                                                <button style="border:none; margin-top:0px" class="muasanpham_1" type="submit" value="submit"><i class="fa fa-shopping-cart"></i> <?php echo lang('form_add_to_cart');?></button>
                                            <?php endif;?>
                                        </div>
                                    </div>
                                    
                                </div>
                                -->
                                <!-- end gia mua theo chu ky-->
                                */?>
                                <div class="product_list_thanhtoan_1" style="clear:both; background:none; padding-bottom:0px">
                                    	<?php echo $product->content_char?>
                                </div>
                                <div align="right"  style="float:left">
                                	
                                    <iframe src="//www.facebook.com/plugins/like.php?href=<?php echo current_url();?>&amp;width=150&amp;layout=button_count&amp;action=like&amp;show_faces=false&amp;share=true&amp;height=21&amp;appId=712944512113995" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:150px; height:21px;" allowTransparency="true"></iframe>                                    <div class="g-plusone" data-size="medium" data-href="<?php echo current_url();?>"></div>									
                                            <script type="text/javascript">
                                              window.___gcfg = {lang: 'vi'};
                                              (function() {
                                                var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
                                                po.src = 'https://apis.google.com/js/platform.js';
                                                var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
                                              })();
                                            </script>
                                            
                                    </div>
                                    <div style="clear:both"></div>
                            	</div>
                            
                        </div>
                       
                        <div class="col-xs-12 col-sm-12 col-md-12">
                        	<div class="production_detail_tab">
                            <ul class="nav nav-tabs" id="myTab">
                              <li class="active"><a href="#mota" data-toggle="tab"><i class="fa fa-arrow-circle-down"></i> Chi tiết sản phẩm</a></li>                              
                              <li><a href="#trahang" data-toggle="tab"><i class="fa fa-arrow-circle-down"></i> Hướng dẫn sử dụng </a></li>
                              <?php if($product->brand_description!=''){?>
                              <li><a href="#brand" data-toggle="tab"><i class="fa fa-arrow-circle-down"></i> Thông tin thương hiệu </a></li>
                              <?php }?>
                              <li><a href="#cmt_pro"  data-toggle="tab"><i class="fa fa-arrow-circle-down"></i> Đánh giá <?php echo !empty($count_cmt)?"(".$count_cmt.")":""?> </a></li>
                              <?php if($product->faq!=''){?>
                              <li><a href="#faq" data-toggle="tab"><i class="fa fa-arrow-circle-down"></i> FAQ </a></li>
                              <?php }?>
                              <!--
                              <li><a href="#giaohang" data-toggle="tab"><i class="fa fa-arrow-circle-down"></i> Đảm bảo</a></li>
                              <li><a href="#baohanh" data-toggle="tab"><i class="fa fa-arrow-circle-down"></i> Bảo hành</a></li>
                              <li><a href="#danhgia" data-toggle="tab"><i class="fa fa-arrow-circle-down"></i> Ý kiến ​​khách hàng </a></li>
                              -->
                            </ul>
                            <div class="tab-content">
                              <div class="tab-pane active" id="mota">
                                <div class="tab_descrition_wp">
                                	<?php echo $product->description?>
                                </div>
                              </div>
                              <div class="tab-pane" id="trahang">
                              	<div class="tab_descrition_wp">
                                	<?php echo $product->post_manual?>
                                </div>
                              </div>
                              <?php if($product->brand_description!=''){?>
                              <div class="tab-pane" id="brand">
                              	<div class="tab_descrition_wp">
                                	<p><b>Thương hiệu <?php echo $product->brand_name;?></b>.</p>
                                	<?php echo $product->brand_description?>
                                </div>
                              </div>
                              <?php }?>
                              <div class="tab-pane" id="cmt_pro" >
                              	<div class="tab_descrition_wp">
                                	<input type="submit" class="btn_comment brn_cmt" value="Viết đánh giá cho sản phẩm">
                                    <div class="frame_cmt">
                                  		<?php echo $this->load->view("ajax/pro_cmt"); ?>
                                    </div>
                                </div>
                              </div>
                              <?php if($product->faq!=''){?>
                              <div class="tab-pane" id="faq">
                              	<div class="tab_descrition_wp">
                                	<?php echo $product->faq?>
                                </div>
                              </div>
                              <?php }?>
                              
                              <!--
                              <div class="tab-pane" id="giaohang">
                              	<div class="tab_descrition_wp">
                                	<?php echo $product->post_warrant?>
                                </div>
                              </div>                              
                              <div class="tab-pane" id="baohanh">
                              	<div class="tab_descrition_wp">
                                	<?php echo $product->post_guarantee?>
                                </div>
                              </div>
                              -->
                              
                              <!-- 
                              <div class="tab-pane" id="danhgia">
                                <div class="tab_descrition_wp">
                                    <div class="box_comment_wp">
                                    <div class="box_comment">
                                        <h5>Tran Duy Minh <span class="price_tag">3/20/2014</span></h5>
                                        <p>Sản phẩm đẹp chất lượng</p>
                                    </div>
                                    <div class="box_comment">
                                        <h5>Tran Duy Minh <span class="price_tag">3/20/2014</span></h5>
                                        <p>Sản phẩm đẹp chất lượng</p>
                                    </div>
                                    <div class="box_comment">
                                        <h5>Tran Duy Minh <span class="price_tag">3/20/2014</span></h5>
                                        <p>Sản phẩm đẹp chất lượng</p>
                                    </div>
                                    <div class="box_comment">
                                        <h5>Tran Duy Minh <span class="price_tag">3/20/2014</span></h5>
                                        <p>Sản phẩm đẹp chất lượng</p>
                                    </div>
                                    </div>
                                    <div class="box_comment_form">
                                        <h4>Gửi đánh giá</h4>
                                        <form class="form-horizontal" role="form">
                                          <div class="form-group">
                                            <label for="inputEmail3" class="col-sm-2 control-label">Tên:</label>
                                            <div class="col-sm-10">
                                              <input type="email" class="form-control" id="inputEmail3">
                                            </div>
                                          </div>
                                          <div class="form-group">
                                            <label for="inputPassword3" class="col-sm-2 control-label">Nội dung</label>
                                            <div class="col-sm-10">
                                              <textarea class="col-md-12 control-label" name="" cols="" rows=""></textarea>
                                            </div>
                                          </div>
                                          <div class="form-group">
                                            <div class="col-sm-offset-2 col-sm-10">
                                              <button type="submit" class="btn btn-default">Gửi</button>
                                            </div>
                                          </div>
                                        </form>
                                    </div>
                                </div>
                              </div>
                              -->
                              
                            </div>
                        </div>
    					</div>
                    </div>
                    <div class="clear"></div>
                </div>
                
                <?php if(!empty($product->related_products)){
				?>
                <div class="box_content">
                	<div class="title_head"><h3><i class="fa fa-dot-circle-o"></i> Sản phẩm liên quan</h3></div>
                    <div class="banner_campaign_wp">
                    	<ul class="box_product_ul">
                    	<?php foreach($product->related_products as $item){
								$array_slug = $item->category; 
								if(count($array_slug)>=2)
									$slug = $array_slug[0]->slug."/".$array_slug[1]->slug;
								else
									$slug = $array_slug[0]->slug;
								$photo  = theme_img('no_picture.png', lang('no_image_available'));
								$item->images    = (array)json_decode($item->images);
								$item->images    = array_values($item->images);
								if(!empty($item->images)){
									$primary    = $item->images[0];
									foreach($item->images as $photo)
									{
										if(isset($photo->primary))
										{
											$primary    = $photo;
										}
									}
									$photo  = '<img src="'.base_url('uploads/images/thumbnails/'.$primary->filename).'" alt="'.$item->seo_title.'"/>';
								}
						?>
                        <li class="box_product_li col-xs-12 col-sm-6 col-md-3" style="text-align:left">
                        	<div class="box_product_wp">
                                <div class="product_image">
                                    <a href="<?php echo site_url($slug.'/'.$item->slug); ?>">
                                        <?php echo $photo?>
                                    </a>
                                </div>
                                <div class="product_text">
                                    <h3><a class="red" href="<?php echo site_url($slug.'/'.$item->slug); ?>"><?php echo $item->name;?></a></h3>
                                    <p><?php echo $item->excerpt; ?></p>
                                </div>
                                <div class="product_price">
                                 		<p class="red">
											<?php if($item->saleprice > 0)echo format_currency($item->saleprice);
                                            	else echo format_currency($item->price);?>
                                        </p>
                                        <div class="button_cart">
                                        	<?php echo form_open('cart/add_to_cart', 'class="form-horizontal"');?>
                                            <input type="hidden" name="cartkey" value="<?php echo $this->session->flashdata('cartkey');?>" />
                                            <input type="hidden" name="id" value="<?php echo $item->id?>"/>
                                            <button class="button-shopping-cart" type="submit" value="submit"><i class="fa fa-shopping-cart"></i></button>
                                            </form>
                                        </div>
                                </div>
                            </div>
                        </li>
                        <?php }?>
                        </ul>
                        <div class="clear"></div>
                    </div>
                </div>
                <?php }?>
                
                <?php // BLOGS ?>
                <?php if(!empty($blogs)){?>
                    <div class="box_content">
                        <div class="title_head">
                            <h3><i class="fa fa-dot-circle-o"></i> Bài viết về sản phẩm</h3>
                        </div>
                        <?php foreach($blogs as $item){?>
                        <div class="col-md-6 frame_blog">
                    	<div class="home_blogs_wp" style="margin-right:10px; border-bottom:1px solid #CCC; padding-bottom:5px; margin-bottom:25px">
                        	<div class="home_blogs_img">
                            	 <a href="<?php echo site_url(BLOGS_DETAIL.$item->slug);?>" sl-processed="1">
									<img style="min-width:350px"src="<?php echo base_url('uploads/images/medium/blogs/'.$item->image);?>">
                                 </a>
                            </div><!-- home_blogs_img --> 
                            <div class="home_blogs_text box">
                            	<h4 style="min-height:40px; margin-bottom:0px"><a href="<?php echo site_url(BLOGS_DETAIL.$item->slug);?>" sl-processed="1"><?php echo $item->title;?></a></h4>
								<p class="text" style="text-align:justify"><?php echo $item->description;?></p>
                            </div> <!-- home_blogs_text -->
                            
                        </div>
                		</div>
                        <?php }?>
                        
                       <div class="clear"></div>
                    </div>
                <?php }?>
                
                <!-- TIN TỨC KHUYẾN MÃI, CAMPAIGN -->
                <?php include ("box_promotion_campaign.php");?>                
                <!-- END TIN TỨC KHUYẾN MÃI, CAMPAIGN -->
                 <!-- VIDEO -->
                <?php $this->banners->show_collection(5, 10, 'video');?>
                <!-- END VIDEO -->
                <!-- BANNER FOOTER -->
                <?php $this->banners->show_collection(3, 2, 'footer_banner');?>
                <!-- END BANNER FOOTER -->                
                
            </div>
            <div style="display:none"><h1><?php echo $product->name;?></h1><h2><?php echo $product->name;?></h2><h3><?php echo $product->name;?></h3><h4><?php echo $product->name;?></h4>
            </div>

<?php /*

<script>
    window.onload = function()
    {
        $('.product').equalHeights();
    }
</script>
<div class="row">
    <div class="span4">
        
        <div class="row">
            <div class="span4" id="primary-img">
                <?php
                $photo  = theme_img('no_picture.png', lang('no_image_available'));
                $product->images    = array_values($product->images);

                if(!empty($product->images[0]))
                {
                    $primary    = $product->images[0];
                    foreach($product->images as $photo)
                    {
                        if(isset($photo->primary))
                        {
                            $primary    = $photo;
                        }
                    }

                    $photo  = '<img class="responsiveImage" src="'.base_url('uploads/images/medium/'.$primary->filename).'" alt="'.$product->seo_title.'"/>';
                }
                echo $photo
                ?>
            </div>
        </div>
        <?php if(!empty($primary->caption)):?>
        <div class="row">
            <div class="span4" id="product_caption">
                <?php echo $primary->caption;?>
            </div>
        </div>
        <?php endif;?>
        <?php if(count($product->images) > 1):?>
        <div class="row">
            <div class="span4 product-images">
                <?php foreach($product->images as $image):?>
                <img class="span1" onclick="$(this).squard('390', $('#primary-img'));" src="<?php echo base_url('uploads/images/medium/'.$image->filename);?>"/>
                <?php endforeach;?>
            </div>
        </div>
        <?php endif;?>
    </div>
    <div class="span8 pull-right">
        
        <div class="row">
            <div class="span8">
                <div class="page-header">
                    <h2 style="font-weight:normal">
                        <?php echo $product->name;?>
                        <?php if($this->session->userdata('admin')): ?>
                        <a class="btn" title="<?php echo lang('edit_product'); ?>" href="<?php echo  site_url($this->config->item('admin_folder').'/products/form/'.$product->id); ?>"><i class="icon-pencil">edit</i></a>
                        <?php endif; ?>
                        <span class="pull-right">
                            <?php if($product->saleprice > 0):?>
                                <small><?php echo lang('on_sale');?></small>
                                <span class="product_price"><?php echo format_currency($product->saleprice); ?></span>
                            <?php else: ?>
                                <small><?php echo lang('product_price');?></small>
                                <span class="product_price"><?php echo format_currency($product->price); ?></span>
                            <?php endif;?>
                        </span>
                    </h2>
                </div>
            </div>
        </div>
        
        <div class="row">
            <div class="span8">
                <?php echo $product->excerpt;?>
            </div>
        </div>
        
        <div class="row" style="margin-top:15px; margin-bottom:15px;">
            <div class="span4 sku-pricing">
                <?php if(!empty($product->sku)):?><div><?php echo lang('sku');?>: <?php echo $product->sku; ?></div><?php endif;?>&nbsp;
            </div>
            <?php if((bool)$product->track_stock && $product->quantity < 1 && config_item('inventory_enabled')):?>
            <div class="span4 out-of-stock">
                <div><?php echo lang('out_of_stock');?></div>
            </div>
            <?php endif;?>
        </div>
        
        <div class="row">
            <div class="span8">
                <div class="product-cart-form">
                    <?php echo form_open('cart/add_to_cart', 'class="form-horizontal"');?>
                    <input type="hidden" name="cartkey" value="<?php echo $this->session->flashdata('cartkey');?>" />
                    <input type="hidden" name="id" value="<?php echo $product->id?>"/>
                    <fieldset>
                    <?php if(count($options) > 0): ?>
                        <?php foreach($options as $option):
                            $required   = '';
                            if($option->required)
                            {
                                $required = ' <p class="help-block">Required</p>';
                            }
                            ?>
                            <div class="control-group">
                                <label class="control-label"><?php echo $option->name;?></label>
                                <?php
                                /*
                                this is where we generate the options and either use default values, or previously posted variables
                                that we either returned for errors, or in some other releases of Go Cart the user may be editing
                                and entry in their cart.
                               
							   
                                //if we're dealing with a textfield or text area, grab the option value and store it in value
                                if($option->type == 'checklist')
                                {
                                    $value  = array();
                                    if($posted_options && isset($posted_options[$option->id]))
                                    {
                                        $value  = $posted_options[$option->id];
                                    }
                                }
                                else
                                {
                                    if(isset($option->values[0]))
                                    {
                                        $value  = $option->values[0]->value;
                                        if($posted_options && isset($posted_options[$option->id]))
                                        {
                                            $value  = $posted_options[$option->id];
                                        }
                                    }
                                    else
                                    {
                                        $value = false;
                                    }
                                }

                                if($option->type == 'textfield'):?>
                                    <div class="controls">
                                        <input type="text" name="option[<?php echo $option->id;?>]" value="<?php echo $value;?>" class="span4"/>
                                        <?php echo $required;?>
                                    </div>
                                <?php elseif($option->type == 'textarea'):?>
                                    <div class="controls">
                                        <textarea class="span4" name="option[<?php echo $option->id;?>]"><?php echo $value;?></textarea>
                                        <?php echo $required;?>
                                    </div>
                                <?php elseif($option->type == 'droplist'):?>
                                    <div class="controls">
                                        <select name="option[<?php echo $option->id;?>]">
                                            <option value=""><?php echo lang('choose_option');?></option>

                                        <?php foreach ($option->values as $values):
                                            $selected   = '';
                                            if($value == $values->id)
                                            {
                                                $selected   = ' selected="selected"';
                                            }?>

                                            <option<?php echo $selected;?> value="<?php echo $values->id;?>">
                                                <?php echo($values->price != 0)?' (+'.format_currency($values->price).') ':''; echo $values->name;?>
                                            </option>

                                        <?php endforeach;?>
                                        </select>
                                        <?php echo $required;?>
                                    </div>
                                <?php elseif($option->type == 'radiolist'):?>
                                    <div class="controls">
                                        <?php foreach ($option->values as $values):

                                            $checked = '';
                                            if($value == $values->id)
                                            {
                                                $checked = ' checked="checked"';
                                            }?>
                                            <label class="radio">
                                                <input<?php echo $checked;?> type="radio" name="option[<?php echo $option->id;?>]" value="<?php echo $values->id;?>"/>
                                                <?php echo($values->price != 0)?'(+'.format_currency($values->price).') ':''; echo $values->name;?>
                                            </label>
                                        <?php endforeach;?>
                                        <?php echo $required;?>
                                    </div>
                                <?php elseif($option->type == 'checklist'):?>
                                    <div class="controls">
                                        <?php foreach ($option->values as $values):

                                            $checked = '';
                                            if(in_array($values->id, $value))
                                            {
                                                $checked = ' checked="checked"';
                                            }?>
                                            <label class="checkbox">
                                                <input<?php echo $checked;?> type="checkbox" name="option[<?php echo $option->id;?>][]" value="<?php echo $values->id;?>"/>
                                                <?php echo($values->price != 0)?'('.format_currency($values->price).') ':''; echo $values->name;?>
                                            </label>
                                            
                                        <?php endforeach; ?>
                                    </div>
                                    <?php echo $required;?>
                                <?php endif;?>
                                </div>
                        <?php endforeach;?>
                    <?php endif;?>
                    
                    <div class="control-group">
                        <label class="control-label"><?php echo lang('quantity') ?></label>
                        <div class="controls">
                            <?php if(!config_item('inventory_enabled') || config_item('allow_os_purchase') || !(bool)$product->track_stock || $product->quantity > 0) : ?>
                                <?php if(!$product->fixed_quantity) : ?>
                                    <input class="span2" type="text" name="quantity" value=""/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                <?php endif; ?>
                                <button class="btn btn-primary btn-large" type="submit" value="submit"><i class="icon-shopping-cart icon-white"></i> <?php echo lang('form_add_to_cart');?></button>
                            <?php endif;?>
                        </div>
                    </div>
                    
                    </fieldset>
                    </form>
                </div>
    
            </div>
        </div>
        
        <div class="row" style="margin-top:15px;">
            <div class="span8">
                <?php echo $product->description; ?>
            </div>
        </div>
        
    </div>
    
    <?php if(!empty($product->related_products)):?>
    <div class="related_products">
        <div class="row">
            <div class="span4">
                <h3 style="margin-top:20px;"><?php echo lang('related_products_title');?></h3>
                <ul class="thumbnails"> 
                <?php foreach($product->related_products as $relate):?>
                    <li class="span2 product">
                        <?php
                        $photo  = theme_img('no_picture.png', lang('no_image_available'));
                        
                        
                        
                        $relate->images = array_values((array)json_decode($relate->images));
                        
                        if(!empty($relate->images[0]))
                        {
                            $primary    = $relate->images[0];
                            foreach($relate->images as $photo)
                            {
                                if(isset($photo->primary))
                                {
                                    $primary    = $photo;
                                }
                            }

                            $photo  = '<img src="'.base_url('uploads/images/thumbnails/'.$primary->filename).'" alt="'.$relate->seo_title.'"/>';
                        }
                        ?>
                        <a class="thumbnail" href="<?php echo site_url($relate->slug); ?>">
                            <?php echo $photo; ?>
                        </a>
                        <h5 style="margin-top:5px;"><a href="<?php echo site_url($relate->slug); ?>"><?php echo $relate->name;?></a>
                        <?php if($this->session->userdata('admin')): ?>
                        <a class="btn" title="<?php echo lang('edit_product'); ?>" href="<?php echo  site_url($this->config->item('admin_folder').'/products/form/'.$relate->id); ?>"><i class="icon-pencil"></i></a>
                        <?php endif; ?>
                        </h5>

                        <div>
                            <?php if($relate->saleprice > 0):?>
                                <span class="price-slash"><?php echo lang('product_reg');?> <?php echo format_currency($relate->price); ?></span>
                                <span class="price-sale"><?php echo lang('product_sale');?> <?php echo format_currency($relate->saleprice); ?></span>
                            <?php else: ?>
                                <span class="price-reg"><?php echo lang('product_price');?> <?php echo format_currency($relate->price); ?></span>
                            <?php endif; ?>
                        </div>
                        <?php if((bool)$relate->track_stock && $relate->quantity < 1 && config_item('inventory_enabled')) { ?>
                            <div class="stock_msg"><?php echo lang('out_of_stock');?></div>
                        <?php } ?>
                    </li>
                <?php endforeach;?>
                </ul>
            </div>
        </div>
    </div>
    <?php endif;?>
</div>
<script>
$(function(){ 
    $('.category_container').each(function(){
        $(this).children().equalHeights();
    }); 
});
</script> */?>

<!-- FlexSlider -->
<?php echo theme_js('jquery.flexslider.js', true);?>
<script type="text/javascript">
/*    $(function(){
      SyntaxHighlighter.all();
    });*/
    $(window).load(function(){
      $('.flexslider').flexslider({
        animation: "slide",
        controlNav: "thumbnails",
        start: function(slider){
          $('body').removeClass('loading');
        }
      });
    });
	$(window).load(function() {
});
</script>
<!-- Optional FlexSlider Additions -->
<?php echo theme_js('jquery.easing.1.3.js', true);?>
<?php echo theme_js('jquery.mousewheel.js', true);?>
<?php echo theme_js('demo.js', true);?>